package com.eques.demo.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.eques.bean.Alarm
import com.eques.demo.R
import com.eques.demo.adapter.viewhoder.AlarmDetailHoder
import com.eques.impl.OnClickListenerImpl


class AlarmAdapter(var context: Context, var beans: List<Alarm> = listOf()) :
    RecyclerView.Adapter<RecyclerView.ViewHolder>() {


    private var onItemClickListener: OnClickListenerImpl? = null

    fun setOnItemClickListener(onItemClickListener: OnClickListenerImpl?) {
        this.onItemClickListener = onItemClickListener
    }


    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        var view = LayoutInflater.from(context)
            .inflate(R.layout.item_animal_alarm_details_layout, parent, false)
        return AlarmDetailHoder(view)
    }

    override fun getItemCount(): Int {
        return beans.size
    }

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        var alarmDetailHoder: AlarmDetailHoder = holder as AlarmDetailHoder
        alarmDetailHoder.setData(context, beans, position)
    }


}